﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Domain.ascx.cs" Inherits="ERP.Modules.Domain" %>

<%-------------------------------%>
<ext:Hidden ID="FormatTypeDomain" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelDomain">
    <Content>
        <%--------------GridDomain-----------------%>
        <ext:GridPanel
            ID="grDomain"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <%-------------StoreDomain-----------------%>
                <ext:Store
                    ID="StoreDomain"
                    runat="server"
                    OnReadData="StoreDomain_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelDomain" runat="server" IDProperty="Domain_Id" GroupField="National_Name">
                            <Fields>
                                <ext:ModelField Name="Domain_Alias" Type="String" />
                                <ext:ModelField Name="Domain_Name" Type="String" />
                                <ext:ModelField Name="Domain_Note" Type="String" />
                                <ext:ModelField Name="National_Name" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="30" Align="Center" />
                    <ext:Column ID="Column2" runat="server" Text="Mã miền" Width="150" DataIndex="Domain_Alias"></ext:Column>
                    <ext:Column ID="Column3" runat="server" Text="Tên miền" Width="200" DataIndex="Domain_Name"></ext:Column>
                    <ext:Column ID="Column1" runat="server" Text="Quốc gia" Width="100" DataIndex="National_Name"></ext:Column>
                    <ext:Column ID="Column5" runat="server" Text="Ghi chú" Width="100" DataIndex="Domain_Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server"
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="DomainDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Domain_Id" Value="record.data.Domain_Id" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModelDomain" runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grDomain}, #{FormatTypeDomain}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar ID="ToolbarPagging" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:SelectBox
                            ID="SelectBoxDomainNational"
                            runat="server"
                            Cls="x-select-box"
                            DisplayField="National_Name"
                            ValueField="National_Id"
                            MarginSpec="0 8 0 0"
                            EmptyText="Chọn quốc gia">
                            <Store>
                                <ext:Store ID="StoreDomainNational" runat="server">
                                    <Model>
                                        <ext:Model runat="server">
                                            <Fields>
                                                <ext:ModelField Name="National_Name" />
                                                <ext:ModelField Name="National_Id" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <DirectEvents>
                                <Select OnEvent="SelectBoxDomainNational_Change">
                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                </Select>
                            </DirectEvents>
                        </ext:SelectBox>
                        <ext:PagingToolbar ID="PagingToolbarDomain" runat="server" StoreID="StoreDomain" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsDomain-----------------%>
        <ext:Window ID="WindowsDomain" runat="server"
            Title="Cập nhật miền"
            DefaultAnchor="100%"
            Width="379px"
            Height="234px"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="false"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarDomain" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelDomain}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtDomain_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelDomain" runat="server"
                    AutoHeight="true"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:TextField ID="txtDomain_Alias" runat="server" FieldLabel="Mã miền" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:TextField ID="txtDomain_Name" runat="server" FieldLabel="Tên miền" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:FieldContainer runat="server" Layout="HBox">
                            <Items>
                                <ext:ComboBox
                                    ID="cbNational"
                                    runat="server"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Quốc gia" AnchorHorizontal="100%" AllowBlank="false"
                                    DisplayField="National_Name"
                                    ValueField="National_Id"
                                    EmptyText="Vui lòng chọn quốc gia"
                                    ContextMenuID="cbNationalContext" MarginSpec="0 5 0 0" Width="310">
                                    <Store>
                                        <ext:Store runat="server" ID="NationalStore" AutoLoad="true" OnReadData="ReloadComboBox">
                                            <Model>
                                                <ext:Model ID="NationalModel" runat="server" IDProperty="National_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="National_Alias" Type="String" />
                                                        <ext:ModelField Name="National_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add">
                                    <Listeners>
                                        <Click Handler="#{WindowsNational}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip runat="server" Html="Thêm mới quốc gia" />
                                    </ToolTips>
                                </ext:Button>
                            </Items>
                        </ext:FieldContainer>
                        <ext:TextArea ID="txtDomain_Note" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <ext:Menu runat="server" ID="cbNationalContext">
            <Items>
                <ext:Button ID="Button4" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbNational}.clearValue(); #{NationalStore}.reload(); #{cbNationalContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
    </Content>
</ext:Panel>
